//TODO fill here
#ifndef __POINTLIGHT__
#define __POINTLIGHT__

#include "RGBColor.h"
#include "Light.h"
#include <math.h>
#include "Objects.h"

namespace Engine
{
	class PointLight : public Engine::Light
	{
	public:
		using Engine::Light::GetDirection;
		Point3D GetDirection(ShadeRec& sr)
		{
			return (m_location - sr.localHitPoint);
		}

		using Engine::Light::L;
		RGBColor L(ShadeRec& sr)
		{
			//check here?
			float inverseDistance = 1 / (pow(GetDirection(sr).length(), 2));
			return (color * m_ls * inverseDistance);
		}

		PointLight()
		{
			color = RGBColor(1);
		}

		PointLight(Point3D& p_location, RGBColor& p_color = RGBColor(1), float p_radius = 1, float p_radiance = 1.0f)
		{
			color = p_color;
			//m_objectRepresentation = new Sphere(p_location, p_radius, p_color);
			SetRadiance(p_radiance);
			SetLocation(p_location);
		}
		using Engine::Light::TestIntersection;
		virtual void TestIntersection(Ray& p_currentRay, ShadeRec& p_details)
		{
			double tmin = INT_MAX;
			m_objectRepresentation->hit(p_currentRay.o, p_currentRay.d, tmin, p_details);
		}

	private:
		RGBColor color;
	};
}

#endif // !__POINTLIGHT__
